#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    double myPow(double x, int n) {
        long long num = n;
        double ret = _myPow(x, abs(num));
        if (n < 0) return 1 / ret;
        else return ret;
    }
    double _myPow(double x, long long n)
    {
        if (n == 0) return 1;
        double num = myPow(x, n / 2);
        return num * num * (n % 2 == 0 ? 1 : x);
    }
};